package es.index.logs.parse.squid;

import java.util.Date;

import es.index.document.logs.squid.SquidCacheLog;
import es.index.logs.parse.LogsBaseParse;

public class SquidCacheLogsParse extends LogsBaseParse {
	
	@Override
	protected Object getLogs() {
		SquidCacheLog scl = new SquidCacheLog();
		scl.set_id(ID());
		scl.set_fileName(_fileName);
		scl.set_date(getDate());
		scl.set_message(_line);
		return scl;
	}

	@Override
	protected Date getDate() {
		_index = _line.indexOf('|');
		String date = new String(_line.substring(0, _index));
		String[] dates = date.split(" |/|:");
		if (getDateField(dates, new String[] { "y", "M", "d", "h", "m", "s" },
				false)) {
			_line = new String(_line.substring(_index + 1).trim());
		}
		return getDates(M - 1, y, d, h, m, s);
	}
}
